/**
 * @计算一个数是不是质数
 *
 * @author	 wangshikun <wangshikun2010@gmail.com>
 * @copyright	(c) 2012 wangshikun <wangshikun2010@gmail.com>
 * @license	http://www.opensource.org/licenses/mit-license.php The MIT License
 * @package	default
 * @subpackage	default
 */

#include <stdio.h>
#include <math.h>

int getnumber(void);
int isprime(int number);

int main(int argc, char *argv[]) {

	if (isprime(getnumber())) {
		printf("是一个质数\n");
	} else {
		printf("不是一个质数\n");
	}

	return 0;
}

int getnumber(void) {
	int number;

	do {
		printf("请输入一个数字：");
		scanf("%d", &number);
	} while (number <= 0);

	return number;
}

int isprime(int number) {
	for (int i=2; i<number; i++) {
		if (number % i == 0) {
			return 0;
		}
	}

	return 1;
}
